#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#include<map>
#include<set>
#include<queue>
#include<list>
#include<cstdlib>
#include<cmath>
#include<sstream>
#include<numeric>
#include<cstdio>
#include<cstring>
#include<stack>
#define PI acos(-1)
#define MP make_pair
#define PB push_back
#define VI vector <int>
#define PII pair <int,int>
#define LL long long
#define SET(v,i) memset(v, i, sizeof(v))
#define FOR(i,a,b) for (int i = (a); i <= (b); i++)
#define FORD(i,a,b) for (int i = (a); i >= (b); i--)
#define FORN(i,a,b) for (int i = (a); i < (b); i++)
#define DOWN(i,a,b) for (int i = (a); i > (b); i--)
#define FIT(it,v) for (typeof(v.begin()) it = v.begin(); it != v.end(); it++)
#define FITD(it,v) for (typeof(v.rbegin()) it = v.rbegin(); it != v.rend(); it++)
using namespace std;
const int N=4500000,mod=1000000007;
LL c[N][4],f[4];
template<class T>
inline T gcd(T a,T b){
    if(a<b)swap(a,b);
    for(T r;b;r=a%b,a=b,b=r);
    return a;   
    }
int main(){
	int w,h;
	scanf("%d%d",&w,&h);
	c[0][0]=1;
	for(int i=1;i<N;i++){
		c[i][0]=1;
		for(int j=1;j<4;j++)c[i][j]=(c[i-1][j]+c[i-1][j-1])%mod;
		}
	
	memset(f,0,sizeof(f));	
	for(int i=0;i<=w;i++){
		for(int j=0;j<=h;j++){
			f[i%2*2+j%2]++;
			}
		}
		
	LL cnt=0;//on line
	for(int i=1;i<=w;i++){
		for(int j=1;j<=h;j++){
			int k=gcd(i,j);
			cnt+=(LL)(w-i+1)*(h-j+1)*(k-1)%mod;
			cnt%=mod;
			}
		}		
	cnt=(cnt*2+c[w+1][3]*(h+1)%mod+c[h+1][3]*(w+1)%mod)%mod;//vertical or horizontal
	LL ans=0,tot=(w+1)*(h+1);
	for(int i=0;i<4;i++){//3 diff or 2 diff
		ans+=c[f[i]][3];
		ans+=c[f[i]][2]*(tot-f[i])%mod;
		ans%=mod; 
		}	
	
	ans=((ans-cnt)%mod+mod)%mod;
	cout<<ans*6%mod<<endl;
    return 0;
    }
